# Maintainer: Alexey Kasatkin <alexeikasatkin@gmail.com>

_realname=libosmpbf
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=1.3.3.13.g4edb4f0
pkgrel=1
pkgdesc="A library to support OpenStreetMap's protocolbuffer binary .pbf format (mingw-w64)"
arch=('any')
url="https://github.com/scrosby/OSM-binary"
license=('LGPL3')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake" "git")
depends=("${MINGW_PACKAGE_PREFIX}-protobuf")
options=('staticlibs' 'strip')
source=("${_realname}::git+https://github.com/scrosby/OSM-binary.git")
sha256sums=('SKIP')

pkgver() {
  cd "${_realname}"
  git describe --tags | sed -e 's|-|.|g' -e 's|v||g'
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
